from PySide6.QtCore import QObject, Slot, Property, QUrl, Signal
from PySide6.QtGui import QGuiApplication
from PySide6.QtQuick import QQuickView
import sys

VIEW_URL = "view.qml"


class ClickModel(QObject):
    """ClickModel定义"""
    def __init__(self):
        # Initialize the parent object. If omitted, GUI will not start
        QObject.__init__(self)
        # Initialize the counter internal value. Because we propagate count as
        # a property to QML, getter, setter and notifier must be made
        
 


        # We set new value and notify of change only if the value
        # is really changed.


    # Declare a notification method
    def zorelu(self):
       return "123"
        # Add a new property to ClickModel object. It can be used as an attribute
    # from Python.
    test = Property(str,zorelu)

    @Slot(str)
    def increase(self,sbc):
        """Handler for the button click. Increases counter by one."""
        print("Increasing")
        print(sbc)
        # Use property as an attribute. Setter is called automatically and
        # notifies the GUI about the changed value.
    


      


app = QGuiApplication(sys.argv)
view = QQuickView()
url = QUrl(VIEW_URL)
# Create the instance of a ClickModel
click_model = ClickModel()

# Get the context of the view
ctxt = view.rootContext()
# Set that 'click_model' will be available as 'clickModel' property in QML
# This must be done before view.setSource is called
ctxt.setContextProperty("clickModel",click_model)

view.setSource(url)
view.show()
app.exec()
